package cn.ctodb.mall.goods.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

import cn.ctodb.mall.goods.domain.enumeration.IsCheck;

/**
 * A Attribute.
 */
@Entity
@Table(name = "attribute")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "attribute")
public class Attribute implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "attr_name")
    private String attrName;

    @Column(name = "attr_input_type")
    private String attrInputType;

    @Enumerated(EnumType.STRING)
    @Column(name = "attr_type")
    private IsCheck attrType;

    @Lob
    @Column(name = "attr_values")
    private String attrValues;

    @Enumerated(EnumType.STRING)
    @Column(name = "attr_index")
    private IsCheck attrIndex;

    @Column(name = "sort_order")
    private Integer sortOrder;

    @Enumerated(EnumType.STRING)
    @Column(name = "is_linked")
    private IsCheck isLinked;

    @Enumerated(EnumType.STRING)
    @Column(name = "attr_group")
    private IsCheck attrGroup;

    @ManyToOne
    private Category category;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAttrName() {
        return attrName;
    }

    public Attribute attrName(String attrName) {
        this.attrName = attrName;
        return this;
    }

    public void setAttrName(String attrName) {
        this.attrName = attrName;
    }

    public String getAttrInputType() {
        return attrInputType;
    }

    public Attribute attrInputType(String attrInputType) {
        this.attrInputType = attrInputType;
        return this;
    }

    public void setAttrInputType(String attrInputType) {
        this.attrInputType = attrInputType;
    }

    public IsCheck getAttrType() {
        return attrType;
    }

    public Attribute attrType(IsCheck attrType) {
        this.attrType = attrType;
        return this;
    }

    public void setAttrType(IsCheck attrType) {
        this.attrType = attrType;
    }

    public String getAttrValues() {
        return attrValues;
    }

    public Attribute attrValues(String attrValues) {
        this.attrValues = attrValues;
        return this;
    }

    public void setAttrValues(String attrValues) {
        this.attrValues = attrValues;
    }

    public IsCheck getAttrIndex() {
        return attrIndex;
    }

    public Attribute attrIndex(IsCheck attrIndex) {
        this.attrIndex = attrIndex;
        return this;
    }

    public void setAttrIndex(IsCheck attrIndex) {
        this.attrIndex = attrIndex;
    }

    public Integer getSortOrder() {
        return sortOrder;
    }

    public Attribute sortOrder(Integer sortOrder) {
        this.sortOrder = sortOrder;
        return this;
    }

    public void setSortOrder(Integer sortOrder) {
        this.sortOrder = sortOrder;
    }

    public IsCheck getIsLinked() {
        return isLinked;
    }

    public Attribute isLinked(IsCheck isLinked) {
        this.isLinked = isLinked;
        return this;
    }

    public void setIsLinked(IsCheck isLinked) {
        this.isLinked = isLinked;
    }

    public IsCheck getAttrGroup() {
        return attrGroup;
    }

    public Attribute attrGroup(IsCheck attrGroup) {
        this.attrGroup = attrGroup;
        return this;
    }

    public void setAttrGroup(IsCheck attrGroup) {
        this.attrGroup = attrGroup;
    }

    public Category getCategory() {
        return category;
    }

    public Attribute category(Category category) {
        this.category = category;
        return this;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Attribute attribute = (Attribute) o;
        if (attribute.id == null || id == null) {
            return false;
        }
        return Objects.equals(id, attribute.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "Attribute{" +
            "id=" + id +
            ", attrName='" + attrName + "'" +
            ", attrInputType='" + attrInputType + "'" +
            ", attrType='" + attrType + "'" +
            ", attrValues='" + attrValues + "'" +
            ", attrIndex='" + attrIndex + "'" +
            ", sortOrder='" + sortOrder + "'" +
            ", isLinked='" + isLinked + "'" +
            ", attrGroup='" + attrGroup + "'" +
            '}';
    }
}
